﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.LIB;
using YJKRevitCode.FormUtility;
using YJKRevitCode.FormUtility.ModelessFormControlSuite.ModelLayer;
using ModelCheckUtility;

namespace FrontRoomCheck.ShowDataForm.ModellessFrame
{
	internal partial class ManualAddFrontRoomForm_ModellessVersion : System.Windows.Forms.Form, IModelessFormSwitch, IModelessFormNoneSwitch
	{
		internal ManualAddFrontRoomForm_ModellessVersion(IWin32Window inputHandle, UIDocument inputDoc)
		{
			//base.Icon = Resource.YArchitechIcon;
			this.RevitHandle = inputHandle;
			this.UiDoc = inputDoc;
			this.InitializeComponent();
			this.m_lstRaidoButtonOfBuildingType.AddRange(new List<RadioButton>
			{
				this.rBtn_FrontRoom,
				this.rBtn_ShareFrontRoom,
				this.rBtn_SpecialRoom
			});
			this.rBtn_AreaDraw.CheckedChanged += this.RBtn_AreaDraw_CheckedChanged;
		}

		public IWin32Window RevitHandle
		{
			get
			{
				return this.m_revitHandle;
			}
			private set
			{
				this.m_revitHandle = value;
			}
		}

		public UIDocument UiDoc
		{
			get
			{
				return this.m_uiDoc;
			}
			private set
			{
				this.m_uiDoc = value;
			}
		}

		public string GetNowRoomTypeString()
		{
			foreach (RadioButton radioButton in this.m_lstRaidoButtonOfBuildingType)
			{
				if (radioButton.Checked)
				{
					return radioButton.Text;
				}
			}
			return string.Empty;
		}

		public bool IfBreak
		{
			get
			{
				return this.m_bIfBreak;
			}
		}

		public bool IfContinue
		{
			get
			{
				return this.m_bIfContinue;
			}
		}

		public bool IfManualEsc
		{
			get
			{
				return this.m_bIfManuEsc;
			}
		}

		public void CloseForm()
		{
			if (!base.IsDisposed)
			{
				base.Close();
			}
		}

		public void ResetContinueBreak()
		{
			this.m_bIfContinue = false;
			this.m_bIfBreak = true;
			this.m_bIfManuEsc = true;
		}

		public void SendEscMessageToRevitAndClearSelect()
		{
			RevitVersionFuncs.ClearSelection(this.UiDoc.Selection);
			Utility.SendEscToHandle(this.RevitHandle);
		}

		public void ShowForm(IWin32Window parentForm = null)
		{
			if (this.RevitHandle != null)
			{
				base.Show(this.RevitHandle);
				return;
			}
			base.Show();
		}

		public void FinishWorkBreakMethod()
		{
			this.m_bIfFinish = true;
			base.Close();
		}

		public int NowCaseIndex
		{
			get
			{
				if (this.rBtn_FrameSel.Checked)
				{
					return 0;
				}
				return 1;
			}
		}

		private void RBtn_AreaDraw_CheckedChanged(object sender, EventArgs e)
		{
			this.BaseCheckChangedMethod();
		}

		private void BaseCheckChangedMethod()
		{
			if (!this.m_bIfNonSendEsc)
			{
				this.m_bIfContinue = true;
				this.m_bIfBreak = false;
				this.m_bIfManuEsc = false;
				this.SendEscMessageToRevitAndClearSelect();
			}
		}

		private void ManualAddFrontRoomForm_ModellessVersion_Load(object sender, EventArgs e)
		{
            List<KeyValuePair<System.Windows.Forms.Control, bool>> list = new List<KeyValuePair<System.Windows.Forms.Control, bool>>();
            KeyValuePair<System.Windows.Forms.Control, bool> item = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_FrameSel, false);
            KeyValuePair<System.Windows.Forms.Control, bool> item2 = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_AreaDraw, false);
            KeyValuePair<System.Windows.Forms.Control, bool> item3 = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_FrontRoom, false);
            KeyValuePair<System.Windows.Forms.Control, bool> item4 = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_ShareFrontRoom, false);
            KeyValuePair<System.Windows.Forms.Control, bool> item5 = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_SpecialRoom, false);
			list.Add(item);
			list.Add(item2);
			list.Add(item3);
			list.Add(item4);
			list.Add(item5);
			ControlInfoManager controlInfoManager = new ControlInfoManager(this, list, null, null);
			this.m_bIfNonSendEsc = true;
			controlInfoManager.SetControlInfoToForm();
			this.m_bIfNonSendEsc = false;
		}

		private void ManualAddFrontRoomForm_ModellessVersion_FormClosed(object sender, FormClosedEventArgs e)
		{
			List<KeyValuePair<System.Windows.Forms.Control, bool>> list = new List<KeyValuePair<System.Windows.Forms.Control, bool>>();
			KeyValuePair<System.Windows.Forms.Control, bool> item = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_FrameSel, false);
			KeyValuePair<System.Windows.Forms.Control, bool> item2 = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_AreaDraw, false);
			KeyValuePair<System.Windows.Forms.Control, bool> item3 = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_FrontRoom, false);
			KeyValuePair<System.Windows.Forms.Control, bool> item4 = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_ShareFrontRoom, false);
			KeyValuePair<System.Windows.Forms.Control, bool> item5 = new KeyValuePair<System.Windows.Forms.Control, bool>(this.rBtn_SpecialRoom, false);
			list.Add(item);
			list.Add(item2);
			list.Add(item3);
			list.Add(item4);
			list.Add(item5);
			ControlInfoManager controlInfoManager = new ControlInfoManager(this, list, null, null);
			controlInfoManager.GetControlInfoToXml();
		}

		private List<Level> m_lstSelectLevel = new List<Level>();

		private IWin32Window m_revitHandle;

		private UIDocument m_uiDoc;

		private List<RadioButton> m_lstRaidoButtonOfBuildingType = new List<RadioButton>();

		private bool m_bIfNonSendEsc;
	}
}
